<template>
    <el-dialog
        title="新闻预览"
        :visible.sync="dialogVisible"
        width="90%"
        @close="handleClose"
        append-to-body
        :before-close="handleClose">
        <div class="news-view-content-page" id="page">
          <div class="main" v-loading="loading">
              <!-- <el-button @click="$router.go(-1)" size="small" style="margin-bottom: 10px">返回</el-button> -->
              <p class="top-title">{{ studentInfo.title }}</p>
              <p class="top-subtitle" v-if="studentInfo.subtitle">{{ studentInfo.subtitle }}</p>
              <p class="top-tip" v-if="studentInfo.releaseTimeStr">
                <span>发布时间: </span>
                <span>{{ studentInfo.releaseTimeStr }}</span>
              
              </p>
              <el-divider></el-divider>
              <div
                class="news-richtext-content"
                v-if="studentInfo.detail"
                v-html="studentInfo.detail.replace(/\n/gm, '<br>')"
              ></div>
              <!--  -->
          </div>
        </div>
    </el-dialog>
</template>
<script>
import { formatDate } from '@/utils/index.js';
import { getNewsStudyInfo } from '@/api/content-manage/researchResult.js';
export default {
  // 组件名称
  name: "ViewNews",
  // 组件参数 接收来自父组件的数据
  props: {},
  // 组件状态值
  data() {
    return {
        dialogVisible: false,
        studentInfo: {},
        total: 0,
        pageIndex: 0,
        loading: true,
        studentId: null,
    };
  },
  created() {
    this.init();
  },
  // 组件方法
  methods: {
    open({id}) {
        this.dialogVisible = true;
        this.getNewsStudyInfo(id);
    },
    async getNewsStudyInfo(id) {
      const { code, data } = await getNewsStudyInfo({id});
      if (code === 0) {
        this.studentInfo = {
          ...data,
          releaseTimeStr: formatDate(data.releaseTime)
        };
      } else {
        this.studentInfo = {};
      }
      
    },
    handleClose() {
      this.dialogVisible = false;
      this.studentInfo = {};
    },
    async init() {
      setTimeout(() => {
        this.loading = false;
      }, 2000)
      
    //   const { data, code } = await getStudentShow({ pageNo: 1, pageSize: 100 });
    },
  },
  mounted() {
    this.init();
  },
};
</script>
<style lang="scss">
  .news-richtext-content {
    position: relative;
    word-break: break-all;
    word-wrap: break-word;
    width: 1200px;
    // max-width: 100%;
    img {
      max-width: 100%;
    }
  }
</style>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.page-com {
  position: relative;
  width: 100%;
  background: #f5f8fa;
}
.news-view-content-page {
  position: relative;
  width: 100%;
  margin: 0 auto;

  .main {
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    .top-title {
      font-size: 30px;
      font-family: PingFangSC-Semibold, PingFang SC;
      font-weight: 600;
      color: #37383D;
      line-height: 42px;
      margin-top: 0;
    }
    .top-subtitle {
      font-size: 22px;
      font-family: PingFangSC-Semibold, PingFang SC;
      font-weight: 600;
      color: #666;
    }
    .top-tip {
      font-size: 14px;
      font-weight: 400;
      color: #9597a0;
      line-height: 20px;
      margin-bottom: 25px;
    }
    .list {
      display: flex;
      justify-content: space-between;
      margin-bottom: 34px;
      .list-item {
        .item-title {
          font-size: 23px;
          font-weight: 500;
          color: #0c0c0c;
          line-height: 32px;
          margin-bottom: 20px;
        }
        .item-test {
          font-size: 23px;
          font-weight: 400;
          color: #0c0c0c;
          line-height: 32px;
          margin-bottom: 42px;
        }
      }
      .list-img {
        width: 464px;
        height: 298px;
      }
    }
    .video {
      width: 632px;
      height: 365px;
      margin: 30px auto 0;
      position: relative;
      .video-img {
        width: 100%;
        height: 100%;
      }
      .video-btn {
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 40%);
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        margin: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        .btn-img {
          width: 87px;
          height: 87px;
        }
      }
    }
    .bottom-nav {
      margin-top: 80px;
      display: flex;
      justify-content: space-between;
      color: #2F8EFE;
      .el-icon-arrow-left {
        margin-right: 10px;
      }
      .el-icon-arrow-right,
      .el-icon-arrow-down {
        margin-left: 10px;
      }
      .nav-item {
        position: relative;
        font-size: 18px;
        font-weight: 500;
        color: #2F8EFE;
        line-height: 33px;
        cursor: pointer;
        &.disabled {
          color: #999;
          cursor: no-drop;
        }
      }
    }
    
  }
}
.student-selecte {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
  overflow-y: scroll;
  .student-item {
    position: relative;
    display: block;
    width: 100%;
    font-size: 18px;
    padding: 0 20px;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #606266;
    height: 34px;
    line-height: 34px;
    box-sizing: border-box;
    cursor: pointer;
  }
  .student-item:hover {
    background-color: #f5f7fa;
  }
}
</style>
